package com.yangjiayu.Controller;

import com.yangjiayu.bean.ChatEntity;
import com.yangjiayu.service.ChatService;
import com.yangjiayu.service.SearXngService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;

/**
 * @Classname InternetController
 * @Description TODO
 * @Date 2025/8/15 17:38
 * @Created by YangJiaYu
 */
@RestController
@RequestMapping("internet")
public class InternetController {


    @Resource
    private SearXngService searXngService;

    @Resource
    private ChatService chatService;

    @GetMapping("/test")
    public Object test(@RequestParam("query")String query){
        return searXngService.search(query);
    }

    @PostMapping("search")
    public void search(@RequestBody ChatEntity chatEntity, HttpServletResponse response){
        response.setCharacterEncoding("UTF-8");
        chatService.doInternetSearch(chatEntity);
    }




}
